{
  LX Package module

  Based on modo's SDK lxpackage.h which is:

  Copyright (c) 2008-2012 Luxology LLC

  Permission is hereby granted, free of charge, to any person obtaining a
  copy of this software and associated documentation files (the "Software"),
  to deal in the Software without restriction, including without limitation
  the rights to use, copy, modify, merge, publish, distribute, sublicense,
  and/or sell copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.   Except as contained
  in this notice, the name(s) of the above copyright holders shall not be
  used in advertising or otherwise to promote the sale, use or other dealings
  in this Software without prior written authorization.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  DEALINGS IN THE SOFTWARE.
}

{
  Copyright (c) 2012 David Ballesteros and Jameel Halabi

  This unit is part of the BLAISEmodo wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}


unit Lx_Package;

{$mode objfpc}{$H+}

interface

uses
  Lx_Result, Lx_Value;

const
  LXa_PACKAGE               = 'package'        ;
  LXa_PACKAGEINSTANCE       = 'packageInstance';
  LXa_SCENE1                = 'scene'          ;

  LXf_LOADIMG_SEARCH_PATHS  = 1 ;
  LXf_LOADIMG_USER_REPLACE  = 2 ;

  LXi_CIT_GROUP             = 1 ;
  LXi_CIT_CLIP              = 2 ;
  LXi_CIT_LOCATOR           = 3 ;
  LXi_CIT_MESH              = 4 ;
  LXi_CIT_LIGHT             = 5 ;
  LXi_CIT_CAMERA            = 6 ;
  LXi_CIT_INSTANCE          = 7 ;
  LXi_CIT_T_LOC             = 8 ;
  LXi_CIT_RENDER            = 9 ;
  LXi_CIT_ENVIRON           = 10;
  LXi_CIT_BACKDROP          = 11;
  LXi_CIT_TLAYER            = 12;

  LXf_SCENETARG_SUBCINE     = 1 ;
  LXf_SCENETARG_NODEFAULTS  = 2 ;
  LXf_SCENETARG_CINECHANGED = 4 ;
  LXf_SCENETARG_GONATIVE    = 8 ;

  LXs_PKG_NODIRECTCREATE    = '-'                    ;
  LXs_PKG_DIRECTCONVERTOK   = '-'                    ;

  LXsPKG_SUPERTYPE          = 'super'                ;

  LXsPKG_GRAPHS             = 'pkg.graphs'           ;
  LXsPKG_CREATECMD          = 'pkg.createCmd'        ;
  LXsPKG_CONVERTCMD         = 'pkg.convertCmd'       ;

  LXsPKG_IS_MASK            = 'isMaskItem'           ;
  LXsPKG_SHADER_CONTEXT     = 'shaderContext'        ;
  LXsPKG_CREATE_INDIRECT    = 'createIndirect'       ;

  LXsCHANVEC_SCALAR         = 'V'                    ;
  LXsCHANVEC_XY             = 'XY'                   ;
  LXsCHANVEC_XYZ            = 'XYZ'                  ;
  LXsCHANVEC_RGB            = 'RGB'                  ;
  LXsCHANVEC_RGBA           = 'RGBA'                 ;

  LXu_ADDCHANNEL            = '{6E732ACC-AAA5-4695-B5DE-8059A2800554}';
  LXu_ITEM1                 = '{5B14C8B6-29EF-473A-B1B3-568DFD9AE8D7}';
  LXu_PACKAGE               = '{6383211E-2624-492e-8C4B-D06BB43886A7}';
  LXu_PACKAGEINSTANCE       = '{09D603F7-CCF6-4A5C-B41C-021AC6C17A94}';
  LXu_SCENE1                = '{4340A8FC-F984-4E04-A4BB-83931A6335AF}';
  LXu_SCENEITEMLISTENER     = '{C72C641E-CDCD-431B-ADD9-D75554D656E1}';
  LXu_SCENEITEMLISTENER1    = '{BCCD05F8-E560-11D7-B3B8-000393CE9680}';

type
  LXtSceneTarget = record
    ItemType ,
    Flags    : Integer;
  end;

  ILxSceneItemListener1 = interface
  [LXu_SCENEITEMLISTENER1]
    procedure SceneCreate   (      Scene    : IUnknown) ;
    procedure SceneDestroy  (      Scene    : IUnknown) ;
    procedure SceneFilename (      Scene    : IUnknown;
                             const Filename : PChar   ) ;
    procedure SceneClear    (      Scene    : IUnknown) ;
    procedure ItemPreChange (      Scene    : IUnknown) ;
    procedure ItemPostDelete(      Scene    : IUnknown) ;
    procedure ItemAdd       (      Item     : IUnknown) ;
    procedure ItemRemove    (      Item     : IUnknown) ;
    procedure ItemParent    (      Item     : IUnknown) ;
    procedure ItemChild     (      Item     : IUnknown) ;
    procedure ItemAddChannel(      Item     : IUnknown) ;
    procedure ItemLocal     (      Item     : IUnknown) ;
    procedure ItemName      (      Item     : IUnknown) ;
    procedure ItemSource    (      Item     : IUnknown) ;
    procedure ItemPackage   (      Item     : IUnknown) ;
    procedure ChannelValue  (const Action   : PChar   ;
                                   Item     : IUnknown;
                                   Index    : UInt32  ) ;
  end;

  ILxSceneItemListener = interface
  [LXu_SCENEITEMLISTENER]
    procedure SceneCreate      (      Scene    : IUnknown) ;
    procedure SceneDestroy     (      Scene    : IUnknown) ;
    procedure SceneFilename    (      Scene    : IUnknown;
                                const Filename : PChar   ) ;
    procedure SceneClear       (      Scene    : IUnknown) ;
    procedure ItemPreChange    (      Scene    : IUnknown) ;
    procedure ItemPostDelete   (      Scene    : IUnknown) ;
    procedure ItemAdd          (      Item     : IUnknown) ;
    procedure ItemRemove       (      Item     : IUnknown) ;
    procedure ItemParent       (      Item     : IUnknown) ;
    procedure ItemChild        (      Item     : IUnknown) ;
    procedure ItemAddChannel   (      Item     : IUnknown) ;
    procedure ItemLocal        (      Item     : IUnknown) ;
    procedure ItemName         (      Item     : IUnknown) ;
    procedure ItemSource       (      Item     : IUnknown) ;
    procedure ItemPackage      (      Item     : IUnknown) ;
    procedure ChannelValue     (const Action   : PChar   ;
                                      Item     : IUnknown;
                                      Index    : UInt32  ) ;
    procedure LinkAdd          (const Graph    : PChar   ;
                                      ItemFrom ,
                                      ItemTo   : IUnknown) ;
    procedure LinkRemBefore    (const Graph    : PChar   ;
                                      ItemFrom ,
                                      ItemTo   : IUnknown) ;
    procedure LinkRemAfter     (const Graph    : PChar   ;
                                      ItemFrom ,
                                      ItemTo   : IUnknown) ;
    procedure LinkSet          (const Graph    : PChar   ;
                                      ItemFrom ,
                                      ItemTo   : IUnknown) ;
    procedure ChanLinkAdd      (const Graph    : PChar   ;
                                      ItemFrom : IUnknown;
                                      ChanFrom : UInt32  ;
                                      ItemTo   : IUnknown;
                                      ChanTo   : UInt32  ) ;
    procedure ChanLinkRemBefore(const Graph    : PChar   ;
                                      ItemFrom : IUnknown;
                                      ChanFrom : UInt32  ;
                                      ItemTo   : IUnknown;
                                      ChanTo   : UInt32  ) ;
    procedure ChanLinkRemAfter (const Graph    : PChar   ;
                                      ItemFrom : IUnknown;
                                      ChanFrom : UInt32  ;
                                      ItemTo   : IUnknown;
                                      ChanTo   : UInt32  ) ;
    procedure ChanLinkSet      (const Graph    : PChar   ;
                                      ItemFrom : IUnknown;
                                      ChanFrom : UInt32  ;
                                      ItemTo   : IUnknown;
                                      ChanTo   : UInt32  ) ;
  end;

  ILxScene1 = interface
  [LXu_SCENE1]
    function  Lookup      (const ID              : PChar   ;
                             out VObj                      ) : LxResult;
    function  ItemCount   (const &Type           : PChar   ) : Integer ;
    function  ItemByIndex (const &Type           : PChar   ;
                                 Index           : UInt32  ;
                             out VObj                      ) : LxResult;
    function  ItemByName  (const Type_is_ignored : PChar   ;
                           const Name            : PChar   ;
                             out VObj                      ) : LxResult;
    function  NewItem     (const &Type           : PChar   ;
                             out VObj                      ) : LxResult;
    procedure GetMeta     (      XObj            : PPointer) ;
    procedure SetMeta     (      XObj            : IUnknown) ;
    function  GetTag      (      &Type           : LXtID4  ) : PChar   ;
    procedure SetTag      (      &Type           : LXtID4  ;
                           const Tag             : PChar   ) ;
    function  Setup       (  out VObj                      ) : LxResult;
    function  Edit        (  out VObj                      ) : LxResult;
    function  Action      (      Time            : Double  ;
                             out VObj                      ) : LxResult;
    procedure ListenAction(      XObj            : IUnknown) ;
    function  LoadImage   (const Name            : PChar   ;
                                 Flags           : PInteger;
                                 Monitor         : IUnknown;
                             out VObj                      ) : LxResult;
  end;

  ILxItem1 = interface
  [LXu_ITEM1]
    function  &Type                                     : PChar   ;
    function  TestType       (const Type_   : PChar   ) : LxResult;
    function  Ident                                     : PChar   ;
    function  GetTag         (      Tag     : UInt32  ) : PChar   ;
    procedure SetTag         (      Type_   : UInt32  ;
                              const Tag     : PChar   )           ;
    function  SubItemCount                              : Integer ;
    function  SubItemByIndex (      Index   : UInt32  ;
                                out VObj              ) : LxResult;
    function  Name                                      : PChar   ;
    procedure SetName        (const Name_   : PChar   )           ;
    procedure Root           (  out VObj              )           ;
    function  Parent         (  out VObj              ) : LxResult;
    procedure SetParent      (      Parent_ : IUnknown;
                                    Pos     : Integer )           ;
    function  ChannelCount                              : Integer ;
    function  ChannelName    (      Index   : UInt32  ) : PChar   ;
    function  ChannelIndex   (const Name_   : PChar   ;
                                    Index   : PUInt32 ) : LxResult;
    function  FindXfrmChannel(const Name_   : PChar   ;
                                    Index   : PUInt32 ;
                                out VObj              ) : LxResult;
  end;

  ILxPackage = interface
  [LXu_PACKAGE]
    function SetupChannels(      AddChan : IUnknown) : LxResult;
    function Attach       (  out VObj              ) : LxResult;
    function TestInterface(const GUID    : PGuid   ) : LxResult;
    function PostLoad     (      Scene   : IUnknown) : LxResult;
  end;

  ILxAddChannel = interface
  [LXu_ADDCHANNEL]
    function  NewChannel   (const Name    : PChar            ;
                            const &Type   : PChar            ) : LxResult;
    function  SetGradient  (const InType  : PChar            ) : LxResult;
    function  SetStorage   (const StType  : PChar            ) : LxResult;
    function  SetVector    (const VecType : PChar            ) : LxResult;
    function  SetDefault   (      DefFlt  : Double           ;
                                  DefInt  : Integer          ) : LxResult;
    function  SetDefaultVec(const DefVec  : PDouble          ) : LxResult;
    function  SetHint      (      Hint    : PLXtTextValueHint) : LxResult;
    function  SetDefaultObj(  out VObj                       ) : LxResult;
    procedure SetInternal                                      ;
  end;

  ILxPackageInstance = interface
  [LXu_PACKAGEINSTANCE]
    function  Initialize(Item     ,
                         Super    : IUnknown) : LxResult;
    procedure Cleanup                         ;
    function  SynthName (Buf      : PChar   ;
                         Len      : UInt32  ) : LxResult;
    function  DupType                         : UInt32  ;
    function  TestParent(Item     : IUnknown) : LxResult;
    function  Newborn   (Original : IUnknown) : LxResult;
    function  Loading                         : LxResult;
    function  AfterLoad                       : LxResult;
    procedure Doomed                          ;
  end;

implementation

end.

